#if !defined(FAKE_UNKNOWN_H)
#define FAKE_UNKNOWN_H

class FakeUnknown : public IUnknown
{
public:
	FakeUnknown()
		: AddRefCalled(false),
		AddRefCalledCount(0),
		AddRefFakeResult(0),
		ReleaseCalled(false),
		ReleaseCalledCount(0),
		ReleaseFakeResult(0)
	{
	}
	virtual ~FakeUnknown() { }

	virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, __RPC__deref_out void __RPC_FAR *__RPC_FAR *ppvObject) { throw std::exception("Not implemented"); }
	virtual ULONG STDMETHODCALLTYPE AddRef(void)
	{
		AddRefCalled = true;
		AddRefCalledCount++;
		return AddRefFakeResult;
	}
	bool AddRefCalled;
	int AddRefCalledCount;
	ULONG AddRefFakeResult;

	virtual ULONG STDMETHODCALLTYPE Release(void)
	{
		ReleaseCalled = true;
		ReleaseCalledCount++;
		return ReleaseFakeResult;
	}
	bool ReleaseCalled;
	int ReleaseCalledCount;
	ULONG ReleaseFakeResult;
};

#define FAKE_UNKNOWN_IMPL(member_)													\
	FakeUnknown member_;															\
	virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject)	\
	{ return member_.QueryInterface(riid, ppvObject); }								\
	virtual ULONG STDMETHODCALLTYPE AddRef()										\
	{ return member_.AddRef(); }													\
	virtual ULONG STDMETHODCALLTYPE Release()										\
	{ return member_.Release(); }

#endif
